/*
  FileName : Mxx_Prototypes.h
  Description:
    This file defines data structures used in Mxx system.
  Created on 2007.9.12 by ZZP.

  Revision History : 

*/


#ifndef __MXX_PROTOTYPES_H__
#define __MXX_PROTOTYPES_H__

#include <std.h>

#define HOST_CF     0
#define USB_CF      1

#define TAX_ON      1
#define TAX_OFF     0

#define COPY_ON     1
#define COPY_OFF    0

#define UART_ON     1
#define UART_OFF    0

#define WORK_STATUS_NORMAL       0
#define WORK_STATUS_GPS_SIMULATE 1
#define WORK_STATUS_HOST_USB     2


#define LED_20HZ_TM       25
#define LED_20HZ_HALF_TM  10

#define LED_5HZ_TM        100
#define LED_5HZ_HALF_TM   50

#define LED_2HZ_TM        250
#define LED_2HZ_HALF_TM   125

#define LED_1HZ_TM        500
#define LED_1HZ_HALF_TM   250


typedef struct
{
  Uns ID_0;
  Uns ID_1;
  Uns CalibData;
  Uns Crc;
}CALIB_PARAM, *pCALIB_PARAM;


typedef struct{
  Uns PosSecIndex;
  Uns StsSecLo;
  Uns StsSecHi;
  Uns WhiteSigFileIndex;
  Uns SigFileIndex;
  Uns TestSecIndex_Offset;
  Uns JwSecIndex;
  Uns Crc;

  Uns rsvd2[8];
}POS_PARAM_IN_NVRAM, *pPOS_PARAM_IN_NVRAM;


struct WINDOWS_TIME_LO_BITS{
  Uns Second   : 6;
  Uns Minute   : 6;
  Uns HourLo   : 4;
};

struct WINDOWS_TIME_HI_BITS{
  Uns HourHi   : 1;
  Uns Date     : 5;
  Uns Month    : 4;
  Uns Year     : 6;
};

union WINDOWS_TIME_LO_REG{
  Uns all;
  struct WINDOWS_TIME_LO_BITS bit;
};

union WINDOWS_TIME_HI_REG{
  Uns all;
  struct WINDOWS_TIME_HI_BITS bit;
};


typedef struct
{
  volatile Uns Second;
  volatile Uns Minite;
  volatile Uns Hour;
  volatile Uns Date;
  volatile Uns Month;
  volatile Uns Year;
}TIME_DATA, *pTIME_DATA;

//Date Time structure
typedef struct
{
  volatile Uns Second;
  volatile Uns Minute;
  volatile Uns Hour;
  volatile Uns Date;  
  volatile Uns Month; 
  volatile Uns Year;  
}DATE_TIME_INFO, *pDATE_TIME_INFO;

typedef struct
{
  volatile DATE_TIME_INFO RtcTime;
  volatile DATE_TIME_INFO SysTime;
  volatile DATE_TIME_INFO TaxTime;
  volatile DATE_TIME_INFO PowOnTime;
}ALL_TIME, *pALL_TIME;

//Disk information structure define
typedef struct{
  volatile Uns Active_Head;
  volatile Uns Sec_Cylinder;
  volatile Uns ID_EndHead;
  volatile Uns EndSec_EndCylinder;
  volatile LgUns RelativeSec;
  volatile LgUns TotSec;
}PARTITION_INFO, *pPARTITION_INFO;

typedef struct
{
  volatile LgUns DiskSz; //Disk sector number
  volatile Uns LBA_Enabled; //
  volatile Uns PartitionIndex;
  volatile Uns PartitionCnt;  //Disk partition : 0 -- C; 1 --- D; and so on.
  volatile PARTITION_INFO PartitionInfo[4];
}DISK_INFO, *pDISK_INFO;


//FAT32 information structure define 
typedef struct
{
  volatile Uns BytesPerSec;
  volatile Uns SecPerClus;
  volatile Uns RsvdSecCnt;
  volatile Uns RootDirSectors;
  volatile Uns NumFATs;
  volatile Uns FATSz32;
  volatile Uns RootEntCnt;
  volatile LgUns TotSec32;
  volatile Uns RootClus;
  
  volatile LgUns CountOfClusters;
  volatile LgUns FirstDataSector;
  volatile Uns FirstFATSector;
  volatile Uns FATCntOfPerSector;
  volatile Uns TotBytesPerClus;

  volatile Uns CF_Type;
  
  volatile LgUns VersSecNo;
  volatile LgUns Version;
  volatile LgUns JwSecStartNo;
  volatile LgUns PosSecStartNo;
  volatile LgUns TestSecStartNo;
  volatile LgUns StsSecStartNo;
  volatile LgUns WhiteSigSecStartNo;
  volatile LgUns SigSecStartNo;
  volatile LgUns MaxSigFileCnt;
}BPB_INFO, *pBPB_INFO;

typedef struct
{
  volatile LgUns NxtFreeClus;
  volatile LgUns FreeClusCnt;
}FSI_INFO, *pFSI_INFO;

//Directory entry structure
typedef struct
{
  //Uns DirName[6];//11 bytes    Offset 0
  //Uns Attr; //1 byte           Offset 11
  //Uns NTRes; //1 byte;         Offset 12
  //Uns CrtTimeTenth;//1 bytes   Offset 13
  volatile Uns DirStart[7];//14 bytes for above data
  volatile Uns CrtTime; //2 bytes       Offset 14
  volatile Uns CrtDate; //2 bytes       Offset 16
  volatile Uns LstAccDate; //2 bytes    Offset 18
  volatile Uns FstClusHi; //2 bytes     Offset 20
  volatile Uns WrtTime; //2 bytes       Offset 22
  volatile Uns WrtDate; //2 bytes       Offset 24
  volatile Uns FstClusLo; //2 bytes     Offset 26
  volatile Uns FileSizeLo; //2 bytes    Offset 28
  volatile Uns FileSizeHi; //2 bytes    Offset 30
}DIR_ENTRY_INFO, *pDIR_ENTRY_INFO;


typedef struct{
  Uns ID[2];
  Uns FileName[11];
  DATE_TIME_INFO Time;
  Uns Version[6];
  LgUns StCnt;
  LgUns MaxSearchDist;
  LgUns FileSize;
  Uns FileClusCnt;
}DATA_BASE_INFO, *pDATA_BASE_INFO;


typedef struct
{

  Uns Tm10Hz;

  Uns PrgVer;
  Uns BiosVer;

  volatile Uns HcWorkF;
  volatile Uns SysStartTm;
  volatile Uns XRamErr;
  volatile Uns SaveParamF;

  Uns UsbExit;
  volatile Uns LedFlashF;


  Uns TxF;
  Uns RxF;
  Uns ErrF;
  Uns WorkF;
  Uns TxTm;
  Uns RxTm;
  Uns ErrTm;
  Uns WorkTm;
  Uns TxCnt;
  Uns RxCnt;
  Uns ErrCnt;
  
  Uns FlashEndTm;
  Uns FlashHalfTm;

  Uns DcWorkF;
  Uns CopySts;

  Uns WorkSts;
  Uns ToBeHandle;

  union WINDOWS_TIME_LO_REG WinTimeLo;
  union WINDOWS_TIME_HI_REG WinTimeHi;
}MY_INFO, *pMY_INFO;

extern volatile MY_INFO MyInfo;

//extern DATE_TIME_INFO NowTm;

extern Uns TskBuf[256];


#endif


//end of file.

